﻿using System;

class CatalanNumber
{

    static double factorial(int n)
    {

        double result = 1;
        for (int i = 1; i <= n; i++)
        {
            result *= i;
        }

       return result;
    }

    static void Main()
    {
        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.WriteLine("9-10. Write a program to calculate the Nth Catalan number by given N.\n");
        Console.ForegroundColor = ConsoleColor.White;
        Console.Write("Enter N =");
        int number = int.Parse(Console.ReadLine());
        double catalanNumber = (double)factorial(2 * number) / (factorial(number + 1) * factorial(number));
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("Catalan number is {0}\n", catalanNumber);
        Console.ForegroundColor = ConsoleColor.White;
    }

}

